<?php
require_once('include/permiss.php');
require_once('config.php');
require_once ('../include/convertm.php');

$order_id = $_GET['order_id'];
$pdo = $conn->prepare('SELECT order_id, datab_product.product_id, product_name, product_price, order_quantity FROM datab_order_product JOIN datab_product ON datab_order_product.product_id=datab_product.product_id  WHERE order_id=?');
$pdo->execute(array($order_id));
if ($pdo->rowCount()) {
    $data = $pdo->fetchAll();
}
?>
<div class="container">
    <div class="box">
        <div class="box-heading">Đơn hàng</div>
        <div class="box-content">
            <form action='delorder.php?token=<?php echo $_SESSION['token']; ?>' method='post'>
                <input type='hidden' name='order_id' value='<?php echo $order_id ?>'>
                <table class="list">
                    <tr bgcolor="#EFEFEF">
                        <th class="image">Xóa</th>
                        <th class="name">Tên món ăn</th>
                        <th class="quantity">Số lượng</th>
                        <th class="quantity">Giá</th>
                        <th class="quantity">Thành tiền</th>
                    </tr>
                    <?php
                    if (isset($data) && count($data)) {
                        $total = 0;
                        foreach ($data as $row) {
                            $total += $row['order_quantity'] * $row['product_price'];
                            ?>
                            <tr>
                                <td class="image"><input type='checkbox' name='products[]' value='<?php echo $row['product_id']; ?>'></td>
                                <td class="name"><?php echo $row['product_name']; ?></td>
                                <td class="quantity"><?php echo $row['order_quantity']; ?></td>
                                <td class="quantity"><?php echo formatMoney($row['product_price']); ?></td>
                                <td class="quantity"><?php echo formatMoney($row['order_quantity'] * $row['product_price']); ?></td>
                            </tr>    
                            <?php
                        }
                    }
                    ?>
                    <tr>
                        <td colspan='4'><font>Tổng tiền</font></td>
                        <td class="quantity"><?php echo formatMoney($total); ?></td>
                    </tr>
                    <tr>
                        <td colspan='5'><font><input type='submit' name='submit' value='Cập nhật'></font></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>    
</div>

